package com.bingbing.back.controller;

import com.bingbing.back.dto.StuInfoDto;
import com.bingbing.back.po.ConsultInfo;
import com.bingbing.back.po.StuInfo;
import com.bingbing.back.service.StuInfoService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/stu")
public class StuInfoController {
    @Resource
    private StuInfoService stuInfoService;
    //根据输入的条件查询信息
    @RequestMapping("/findByParam")
    public PageInfo<StuInfo> findByParam(int pageNum,int pageSize,StuInfoDto dto){
        PageInfo<StuInfo> page=null;
        page=stuInfoService.findByParam(pageNum,pageSize,dto);
        return page;
    }
    //根据学生账号删除
    @RequestMapping("/delete")
    public int delete(Integer stuId){
        Integer row=0;
        row=stuInfoService.doDelete(stuId);
        return row;
    }

    /**
     * 返回可用的咨询师
     * @return 返回咨询师编号consultId和咨询师真实姓名consultRealName
     */
    @RequestMapping("/showAbleConsult")
    List<ConsultInfo> showAbleConsult(){
        return stuInfoService.showAbleConsult();
    }

    /**
     * 给考生对应相应的咨询师编号
     * @param stuId
     * @param consultId 当consultId=-1时给考生解绑咨询师
     * @return
     */
    @RequestMapping("/updateConsult")
    int updateConsult(int stuId, int consultId){
        return stuInfoService.updateConsult(stuId, consultId);
    }
}
